<?php
require_once($_SERVER['DOCUMENT_ROOT'].'/ukkepuk/source/php/classes/validation/Inputvalidation.php');
require_once($_SERVER['DOCUMENT_ROOT'].'/ukkepuk/source/php/classes/dao/UserDao.php');
require_once($_SERVER['DOCUMENT_ROOT'].'/ukkepuk/source/php/classes/web/UserLogin.php');
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Login
 *
 * @author virtual
 */
class UserLogin {
    public static function setupUser($user, $password){
        $userdao = new UserDao();
        //validate against db
        
        if(InputValidation::isValidUsername($user) && 
           InputValidation::isValidPassword($password)) {
           if($userdao->checkLogin($user, $password)){
                Session::setUser($user);       
                $x = $userdao->getRolesForUser($user);
                Session::setRole($userdao->getRolesForUser($user));
                
           }
        }
    }
    
    public static function isLoggedIn() {
        return Session::getUser() != null;
    }
    
    public static function logoff() {
        Session::clear();
    }
}

?>
